package entidade;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@SequenceGenerator(name = "PK_CHAMADO", sequenceName = "GEN_CHAMADO_ID")
@NamedQueries({
	@NamedQuery(name = "chamado.findAll", query = "select c from Chamado c "
			+ "order by c.codigo"),
	@NamedQuery(name = "chamado.findByUsuario", query = "select c from Chamado c where c.usuario.codigo = :codigo order by c.codigo asc"),
	@NamedQuery(name = "chamado.findBySituacao", query = "select c from Chamado c where c.situacao.codigo = :situacao order by c.codigo asc"),
	@NamedQuery(name = "chamado.findByUsuarioSituacao", query = "select c from Chamado c where c.usuario.codigo = :codigo and c.situacao.codigo = :situacao order by c.codigo asc")
})
@Table(name = "chamado")
public class Chamado {
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "PK_CHAMADO")
	@Column(name="cd_chamado")
	private Integer codigo;
	@JoinColumn(name="cd_responsavel", referencedColumnName="cd_usuario")
	@ManyToOne(fetch = FetchType.LAZY)
	private Usuario responsavel;
	@JoinColumn(name="cd_usuario", referencedColumnName="cd_usuario")
	@ManyToOne(fetch = FetchType.LAZY)
	private Usuario usuario;
	@JoinColumn(name="cd_situacao", referencedColumnName="cd_situacao")
	@ManyToOne(fetch = FetchType.LAZY)
	private Situacao situacao;
	@Temporal(TemporalType.DATE)
	private Date dtRegistro;
	@Temporal(TemporalType.DATE)
	private Date dtPrevisao;
	@Temporal(TemporalType.DATE)
	private Date dtConclusao;
	private byte[] solicitado;
	private byte[] solucao;
	private byte[] causa;
	
	public Integer getCodigo() {
		return codigo;
	}
	public void setCodigo(Integer codigo) {
		this.codigo = codigo;
	}
	public Usuario getResponsavel() {
		return responsavel;
	}
	public void setResponsavel(Usuario responsavel) {
		this.responsavel = responsavel;
	}
	public Usuario getUsuario() {
		return usuario;
	}
	public void setUsuario(Usuario usuario) {
		this.usuario = usuario;
	}
	public Situacao getSituacao() {
		return situacao;
	}
	public void setSituacao(Situacao situacao) {
		this.situacao = situacao;
	}
	public Date getDtRegistro() {
		return dtRegistro;
	}
	public void setDtRegistro(Date dtRegistro) {
		this.dtRegistro = dtRegistro;
	}
	public Date getDtPrevisao() {
		return dtPrevisao;
	}
	public void setDtPrevisao(Date dtPrevisao) {
		this.dtPrevisao = dtPrevisao;
	}
	public Date getDtConclusao() {
		return dtConclusao;
	}
	public void setDtConclusao(Date dtConclusao) {
		this.dtConclusao = dtConclusao;
	}
	public byte[] getSolicitado() {
		return solicitado;
	}
	public void setSolicitado(byte[] bs) {
		this.solicitado = bs;
	}
	public byte[] getSolucao() {
		return solucao;
	}
	public void setSolucao(byte[] solucao) {
		this.solucao = solucao;
	}
	public byte[] getCausa() {
		return causa;
	}
	public void setCausa(byte[] causa) {
		this.causa = causa;
	}
	
}
